<?php $this->load->view('student_home/_header')?>
<?php $this->load->view('message') ?>
<script type="text/javascript">
  $().ready(function(){
    $("#main_page_li").addClass("active");
    $("#choose_logic_class_form").validate({
            rules:{
                logic_class_number:
                {
                    required:true,
                    maxlength:200
                }
            }
        });
  });

  function addLoadEvent(func){
        var oldonload = window.onload;
        if (typeof window.onload != 'function'){
            window.onload = func;
            }
        else{
            window.onload = function(){
                oldonload();
                func();
                }
            }
    }

    function password_change()
    {
        var change_password = <?php echo $change_password?>;
        if (!change_password) {
            if(confirm("密码不要与用户名相同，请修改密码，并妥善保存！"))
                location.href="<?php echo site_url('student_home/change_password')?>";
        }
    }
    addLoadEvent(password_change);
    function delete_item(logic_class_id,student_id)
    {
        if(confirm("将退选课程，确定吗？"))
            location.href="<?php echo site_url('student_home/delete_student_in_logic_class').'/'?>"+logic_class_id+"/"+student_id;
    }
</script>
    
    <div class="container">
    <div class="col-md-3">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">个人信息</h3>
            </div>
             <div class="panel-body">
                <div class="row form-group" style="border-bottom:1px ridge;">
                  <label  class="col-lg-4 control-label">姓名</label>
                  <div class="col-lg-8">
                        <label  class="ontrol-label"><?php echo $student['name']?></label>
                  </div>
                </div>
                <div class="row form-group" style="border-bottom:1px ridge;">
                  <label  class="col-lg-4 control-label">学号</label>
                  <div class="col-lg-8">
                        <label  class="ontrol-label"><?php echo $student['student_id']?></label>
                  </div>
                </div>
                <div class="row form-group" style="border-bottom:1px ridge;">
                  <label  class="col-lg-4 control-label">专业</label>
                  <div class="col-lg-8">
                        <label  class="ontrol-label"><?php echo $major['name']?></label>
                  </div>
                </div>
            </div>
        </div>
    </div>


    <div class="col-md-9">

<div class="panel panel-primary">
        <div class="panel-heading">

                <h3 class="panel-title">课程信息</h3>
        </div>
        <div class="panel-body">
            <!-- <?php echo validation_errors(); ?>
            <form id="choose_logic_class_form" method="post" class="form-horizontal"  enctype="multipart/form-data" action="<?php echo site_url('student_home/choose_logic_class')?>
                " >
                <fieldset>
                    <input type="text" id="student_id" name="student_id" value="<?=$student['id'];?>" class="hidden"/>
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label class="col-lg-4 control-label">班级名称:</label>
                                <div class="col-lg-8">
                                    <input class="form-control" id="logic_class_name" name="logic_class_name"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="form-group">
                                <div class="col-lg-11 col-lg-offset-1">
                                    <button type="submit" class="btn btn-primary">选课</button>
                                </div>
                            </div>
                        </div>
                    </div>                    
                </fieldset>
            </form> -->
            <?php if($all_logic_class_module==null){?>
                <div class="panel panel-default">
                    
                        <div class="panel-heading" role="tab" id="heading">
                          <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapse" aria-expanded="true" aria-controls="collapse">
                                选课列表（点击展开）
                            </a>
                          </h4>
                        </div>
                    
                        <div id="collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading">
                          <div class="panel-body">
                                
                                    <table class="table table-striped table-hover ">
                                        <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>班级</th>
                                                <th>课程</th>
                                                <th>教师</th>
                                                <th>编号</th>
                                                <th></th>
                                                <th></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $i=1; ?>
                                            <?php foreach ($logic_classes_for_choose as $logic_class_item): ?>
                                            <tr>
                                                <td>
                                                    <?php echo $i++ ;?></td>
                                                <td>
                                                    <?php echo $logic_class_item['name']?></td>
                                                <td>
                                                    <?php echo $logic_class_item['big_lecture_name']?></td>
                                                <td>
                                                    <?php echo $logic_class_item['teacher_name']?></td>
                                                <td>
                                                    <?php echo $logic_class_item['teacher_number']?></td>
                                                <td></td>
                                                <td><a href="<?php echo site_url('student_home/choose_logic_class').'/'.$logic_class_item['id']?>" class="btn btn-primary ">选课</a></td>
                                            </tr>

                                            <?php endforeach; ?></tbody>
                                    </table>
                          </div> 
                        </div>
                    </div>
            </div>
        <?php }?>
        <div class="bs-example">
            <table class="table table-striped">
              <tbody>
                    
                <?php  $i=1; foreach ($all_logic_class_module as $item_logic_class ): ?>   
                
                <tr  class="success">                  
                    <th>课程名称</th>
                    <th><?php echo $item_logic_class['big_lecture_name']?></th>                 
                    <th>班级名称</th>
                    <th><?php echo $item_logic_class['logic_class_name']?></th>
                    <th></th>
                    <th></th>
                    <th><a onclick="delete_item(<?=$item_logic_class['id']?>,<?=$student['id']?>)" href="#" class="btn btn-danger">退课</a></th>
                </tr>
                
                 <tr>
                    <th></th>
                    <th>科目</th>
                    <th>时间限制</th>
                    <th>状态</th>
                    <th>考试时间</th>
                    <th>分数</th>
                    <th>操作</th>
                </tr>
              <?php  foreach ($item_logic_class['module_add_logic_class'] as $item_module ): ?>
                <tr>
                    <th><?php echo $i; $i++;?></th>
                    <td><?php echo $item_module['name']?></td>
                    <td><?php echo $item_module['time_limit']?></td>
                    <td>
                        <?php if ($item_module['report_state']==2): ?>
                            未考试
                        <?php elseif ($item_module['report_state']==0): ?>
                            正在考试
                        <?php elseif ($item_module['report_state']==1): ?>
                            已考试
                        <?php endif ?>
                    </td>
                    <!-- <td><?php if ($item_module['report_id'] == 0) {
                         echo '未考试';
                    }
                    else{echo '已考试';
                        }?></td> -->
                    <td><?php echo $item_module['report_datetime']?></td>
                    <td><?php echo $item_module['report_grades']?></td>

                    <?php 
                    $module_id = $item_module['id']; 
                    $report_id = $item_module['report_id']; 
                    $logic_class_id = $item_logic_class['logic_class_id']; 
                    ?>
                    <td>
                        <?php if ($item_module['report_state']==2): ?>
                             <a href="<?php echo site_url('student_test/test').'/'.$student['id'].'/'.$module_id.'/'.$logic_class_id.'/'.$item_module['time_limit']?>" class="btn btn-primary ">
                                去考试
                            </a>
                        <?php elseif ($item_module['report_state']==0): ?>
                             <a href="<?php echo site_url('student_test/test').'/'.$student['id'].'/'.$module_id.'/'.$logic_class_id.'/'.$item_module['time_limit']?>" class="btn btn-primary ">
                                继续考试
                            </a>
                        <?php elseif ($item_module['report_state']==1): ?>
                                <?php if ($item_module['check_limit']==1): ?>
                                <a href="<?php echo site_url('student_test/check').'/'.$report_id.'/'.$module_id.'/'.$logic_class_id.'/'.$student['id']?>" class="btn btn-primary ">
                                    查看(七日内)
                                </a>
                                <?php elseif ($item_module['check_limit']==0): ?>
                                查看期限已过
                                <?php endif ?>
                        <?php endif ?>
                    </td>

                    <!-- <td>
                    <?php 
                    $module_id = $item_module['id']; 
                    $report_id = $item_module['report_id']; 
                    $logic_class_id = $item_module['logic_class_id']; 
                    if ($report_id==0) { ?>
                            <a href="<?php echo site_url('student_test/test').'/'.$student['id'].'/'.$module_id.'/'.$logic_class_id.'/'.$item_module['time_limit']?>" class="btn btn-primary ">
                                去考试
                            </a>
                    <?php }  
                    else { ?>
                            <a href="<?php echo site_url('student_test/check').'/'.$report_id.'/'.$module_id.'/'.$logic_class_id.'/'.$student['id']?>" class="btn btn-primary ">
                                查看
                            </a>
                    <?php } ?>
                    </td> -->
                </tr>
               <?php endforeach; ?>
               <?php endforeach; ?>
              </tbody>
            </table>
        </div>
        
    </div>

    </div>
</div>

<?php $this->load->view('student_home/_footer')?>